<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item :label="$t('m.eform.appgroup.other.group_name')">
              <group-id-tag :placeholder="$t('m.eform.formDesign.label.qing-xuan-ze-suo-shu-ying-yong')" v-model="queryParam.catalogId"></group-id-tag>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item :label="$t('m.bpm.entity.name')">
              <a-input placeholder="" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{ $t('m.common.button.query') }}</a-button>
              <a-button type="default" @click="searchReset" icon="reload" style="margin-left: 8px">{{ $t('m.common.button.reset') }}</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        :rowKey="rowKey"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: (radio ? 'radio' : 'checkbox')}"
        @change="handleTableChange"
        :customRow="clickThenCheck"
      >
        <template slot="serialNum" slot-scope="text,record,index">
          {{(ipagination.current-1) * ipagination.pageSize + parseInt(index) + 1}}
        </template>
      </a-table>
    </div>
  </a-card>
</template>

<script>

  import { YcListMixin } from '@/mixins/YcListMixin'
  import { filterMultiDictText } from '@/components/dict/YchDictSelectUtil'
  import { BpmConstant } from '../../BpmConstant'
  import GroupIdTag from '../../../eform/select/tag/GroupIdTag'
  import YchConstant from "@/api/YchConstant";

  export default {
    name: 'ProcessDefList',
    mixins: [YcListMixin],
    components: {
      GroupIdTag
    },
    props: {
      radio: Boolean,
    },
    data () {
      return {
        columns: [{
          title:this.$t('m.common.label.number'),
          dataIndex: '',
          key: 'rowIndex',
          width: 50,
          align: 'center',
          scopedSlots: { customRender: 'serialNum' },
        }, {
          title: this.$t('m.bpm.entity.name'),
          align: 'center',
          width: 180,
          dataIndex: 'name'
        }, {
          title: this.$t('m.bpm.entity.key'),
          align: 'center',
          width: 150,
          dataIndex: 'key'
        }, {
          title: this.$t('m.bpm.entity.version'),
          align: 'center',
          width: 80,
          dataIndex: 'version'
        }, {
          title: this.$t('m.bpm.entity.status'),
          align: 'center',
          width: 80,
          dataIndex: 'status',
          customRender: (text) => {
            if (!text) {
              return ''
            } else {
              return filterMultiDictText(BpmConstant.processDefStatus, text)
            }
          }
        }],
        url: {
          list: YchConstant.PREFIX_BPM + '/bpm-front/processDefRest/list/v1',
        },
      }
    },
    methods: {}
  }
</script>
